//
//  YGOwnhelpView.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/3/22.
//

#import "YGOwnhelpView.h"


@interface YGOwnhelpView ()


@property (nonatomic, strong)UILabel *ownhelpLable;
@property(nonatomic, strong)UIImageView *ownhelpImage;


@end

@implementation YGOwnhelpView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initView];
        [self initContraints];
    }
    return self;
}

- (void)initView{
    
    [self addSubview:self.ownhelpBtn];
    [self addSubview:self.ownhelpLable];
    [self addSubview:self.ownhelpImage];
}


- (void)initContraints{
    
    [self.ownhelpBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mas_top);
        make.left.mas_equalTo(self.mas_left);
        make.width.mas_equalTo(self.mas_width);
        make.height.mas_equalTo(self.mas_height);
    }];
    
    [self.ownhelpLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(15);
            make.left.mas_equalTo(self.mas_left).offset(10);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(16);
            
    }];
    
    [self.ownhelpImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.mas_equalTo(self.mas_centerY);
            make.right.mas_equalTo(self.mas_right).offset(-20);
            make.height.mas_equalTo(66.5);
        make.width.mas_equalTo(76.5);
            
    }];
}

-(void)clickInfoOwnHelpAction{
    if (self.ownHelpViewDelegate != nil && [self.ownHelpViewDelegate respondsToSelector:@selector(ownHelpViewInfoOwnHelpControllerAction)]) {
        [self.ownHelpViewDelegate ownHelpViewInfoOwnHelpControllerAction];
    }
}


#pragma setter

- (UIButton *)ownhelpBtn{
    if (!_ownhelpBtn) {
        _ownhelpBtn=[[UIButton alloc]init];
        [_ownhelpBtn addTarget:self action:@selector(clickInfoOwnHelpAction) forControlEvents:UIControlEventTouchUpInside];
        _ownhelpBtn.backgroundColor=UIColorFromRGB(0xFFF7EF);
        _ownhelpBtn.layer.cornerRadius=5;
    }
    return _ownhelpBtn;
}

- (UILabel *)ownhelpLable{
    if (!_ownhelpLable) {
        _ownhelpLable=[[UILabel alloc]init];
        _ownhelpLable.text=@"营养自助";
        _ownhelpLable.textColor=UIColorFromRGB(0xEAA968);
        _ownhelpLable.font=[UIFont fontWithName:@"Helvetica-Bold" size:16];
        
    }
    return _ownhelpLable;
}

- (UIImageView *)ownhelpImage{
    if (!_ownhelpImage) {
        _ownhelpImage= [[UIImageView alloc]init];
        [_ownhelpImage setImage:[UIImage imageNamed:@"ownhelp_box_icon"]];
    }
    return _ownhelpImage;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
